<template>
    <div class="editEsSmsInteraction-container">
        <!-- 弹框 -->
        <el-dialog v-model="state.isShowDialog" draggable width="769px">
            <template #header>
                <div style="color: #fff">
                    <el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle">
                        <ele-Edit/>
                    </el-icon>
                    <span> {{ props.title }} </span>
                </div>
            </template>
            <el-form :model="state.ruleForm" ref="ruleFormRef" size="default" label-width="80px">
                <el-row :gutter="35">
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="产品名称" prop="productChannelCode">
                            <el-input :value="state.ruleForm.productName" placeholder="产品名称" class="w100" readonly/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="手机号码" prop="phone">
                            <el-input :value="state.ruleForm.phone" placeholder="手机号码" class="w100" readonly/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="省-市" prop="province">
                            <el-input
                                :value="`${state.ruleForm.province || ''}-${state.ruleForm.city ? state.ruleForm.city : ''}`"
                                placeholder="省-市" class="w100" readonly/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="验证码" prop="channelVerifyCode">
                            <el-input :value="state.ruleForm.channelVerifyCode" placeholder="验证码" class="w100"
                                      readonly/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="运营商" prop="operatorPlatform">
                            <el-select v-model="state.ruleForm.operatorPlatform" placeholder="请选择" class="w100"
                                       disabled>
                                <el-option v-for='item in optionDict.operatorPlatformDict' :key='item.value'
                                           :label='item.label' :value='item.value'/>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="来源" prop="advSource">
                            <el-input :value="state.ruleForm.advSource" placeholder="来源" class="w100" readonly/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="App包名" prop="advAppPackageName">
                            <el-input :value="state.ruleForm.advAppPackageName" placeholder="App包名" class="w100"
                                      readonly/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="请求IP" prop="channelRequestIP">
                            <el-input :value="state.ruleForm.channelRequestIP" placeholder="请求IP" class="w100"
                                      readonly/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                        <el-form-item label="请求时间" prop="createTime">
                            <el-input v-model="state.ruleForm.createTime" placeholder="创建时间" class="w100" readonly/>
                        </el-form-item>
                    </el-col>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label="UserAgent" prop="channelUserAgent">
                            <el-input :value="state.ruleForm.channelUserAgent" placeholder="UserAgent" class="w100"
                                      type="textarea" style="word-break: break-all;" :autosize="{ minRows: 2 }"
                                      readonly/>
                        </el-form-item>
                    </el-col>
                    <el-divider border-style="dashed"/>
                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
                        <el-form-item label-width="0px" label="" class="cor">
                            <div class="log-container">
                                <div class="log-entry">
                                    <div class="timestamp">订购日志 {{ state.ruleForm.createTime }}</div>
                                    <div class="message">INFO: 用户{{ state.ruleForm.phone }}发起计费</div>
                                    <div class="details"><p>
                                        发送短信报文：{{ state.ruleForm.channelChargingRequestUrl?.split('?')[1] }}</p>
                                        <p>响应报文：{{ state.ruleForm.channelChargingResponse }}</p></div>
                                    <div class="details" v-if="state.ruleForm.channelVerifyRequestUrl?.split('?')[1]">
                                        <p>提交验证码报文：{{
                                                state.ruleForm.channelVerifyRequestUrl?.split('?')[1]
                                            }}</p>
                                        <p>响应报文：{"ResCode":"0000","ResMessage":"成功"}</p></div>
<!--                                    <p>响应报文：{{ state.ruleForm.channelVerifyResponse }}</p></div>-->
                                </div>
                            </div>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <template #footer>
				<span class="dialog-footer">
					<el-button type="primary" @click="closeDialog" size="default">关 闭</el-button>
				</span>
            </template>
        </el-dialog>
    </div>
</template>

<script lang="ts" setup name="editEsSmsInteraction">

import {reactive, ref} from 'vue';

import {EsSmsInteraction} from '/@/api/models';
import {optionDict} from "/@/const/dict";
// 定义变量内容
const props = defineProps({
    title: String,
});

const ruleFormRef = ref();
const state = reactive({
    isShowDialog: false,
    ruleForm: {} as EsSmsInteraction,
});

// 打开弹窗
const openDialog = async (row: EsSmsInteraction, conDition: string) => {
    state.ruleForm = row;
    state.isShowDialog = true;
};

// 关闭弹窗
const closeDialog = () => {
    state.isShowDialog = false;
};

// 导出对象 将属性或者函数暴露给父组件
defineExpose({openDialog});
</script>

<style lang="scss" scoped>
.log-container {
    width: 100%;
    max-width: 100%;
    padding: 5px;
    background-color: #222222;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.log-entry {
    /* margin-bottom: 20px; */
    padding: 3px;
    background-color: #333333;
    border: 1px solid #444444;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.1);
}

.log-entry .timestamp {
    color: #999999;
    font-size: 12px;
    margin-bottom: 5px;
}

.log-entry .message {
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
}

.log-entry .details {
    margin-top: 5px;
    padding-left: 15px;
    color: #cccccc;
    font-size: 12px;
    line-height: 1.2;
    display: inline-block;
    word-break: break-all;
    word-wrap: break-word;
    white-space: normal;
}

:deep(.custom-form-item-red) .el-form-item__label {
    color: #ff0000; /* 红色 */
    //font-weight: bold;
}

:deep(.custom-form-input-red) .el-textarea__inner {
    color: #ff8c00;
}


</style>
